﻿// Picturez
//
// Copyright © Frank Nagl, 2008-2012
// admin@franknagl.de
// www.franknagl.de
//
namespace Picturez
{
    using System;
    using System.Windows.Forms;
    using System.Diagnostics;

    partial class MainForm
    {
        private void ImagesKryptonListBoxMouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (ImagesKryptonListBox.Items.Count == 0)
                return;
            ImageCutForm form = new ImageCutForm(images[ImagesKryptonListBox.SelectedIndex]);
            form.Show(this);
        }

        private void MainFormFormClosing(object sender, FormClosingEventArgs e)
        {
            Program.SaveXml(configs);

            pipeThread.Abort();
            Process[] procs = Process.GetProcessesByName(
                                       Process.GetCurrentProcess().ProcessName);
            foreach (Process p in procs)
            {
                p.Kill();
            }
        }

        private void MainFormDragOver(object sender, DragEventArgs dea)
        {
            if (dea.Data.GetDataPresent(DataFormats.FileDrop))
                dea.Effect = DragDropEffects.Move;
        }

        private void MainFormDragDrop(object sender, DragEventArgs dea)
        {
            if (dea.Data.GetDataPresent(DataFormats.FileDrop))
            {
                string[] files = (string[])dea.Data.GetData(DataFormats.FileDrop);
                AddImages(files);
            }
        }

        private void QualityTrackBarScroll(object sender, EventArgs e)
        {
            QualityKryptonTextBox.Text = QualityTrackBar.Value.ToString();
            Current.JpgQuality = (byte)QualityTrackBar.Value;
        }
    }
}
